<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>js入门体验</title>
</head>

<body>
  <a href="./index.html">返回二阶段的首页</a>
  |
  <a href="../index.html">返回网站首页</a>

  <hr>

  <button id="btn1">按钮</button>
  <input type="text" id="username">
  <span id="spinfo"></span>

  <!-- 
    javascript的内容需要放在script标记中
    js可以响应用户的行为，还可以动态修改页面的内容，还可以和后端服务器交互数据
  -->
  <script>

    let btn1 = document.getElementById('btn1')
    let username = document.getElementById('username')
    let spinfo = document.getElementById('spinfo')

    btn1.addEventListener('click', () => {
      spinfo.innerHTML = '输入的内容是：' + username.value
      alert(username.value)
    })

  </script>

</body>

</html>